package com.aaa.dao.impl;

import com.aaa.dao.UserInfoDao;
import com.aaa.entity.Userinfo;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/6/20 9:21
 * @description：
 * @modified By：
 * @version:
 */
public class UserInfoDaoImpl  implements UserInfoDao {
    private JdbcTemplate jdbcTemplate;

    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public List<Userinfo> findAllUser() {
        BeanPropertyRowMapper<Userinfo> rowMapper = new BeanPropertyRowMapper<>(Userinfo.class);
        List<Userinfo> userinfoList = jdbcTemplate.query("select * from userinfo", rowMapper);
        return userinfoList;
    }

    @Override
    public void deleteUserInfoById(Integer userid) {
        jdbcTemplate.update("delete  from userinfo where userid=?", userid);
    }
}
